<?php
namespace haibao\cms\business\behavior;

use \haibao\cms\data\behavior\SiteMonitor as SiteMonitorData;
use \haibao\cms\business\BusinessException;
class SiteMonitor extends \haibao\cms\business\Base{
    
    public static function getExtensionRegionPer($pageId,$startDate,$endDate,$str){
        $data = new SiteMonitorData();
        
        return $data->getExtensionRegionPer($pageId,$startDate,$endDate,$str);
    }
    
	public static function getRegionChart($pageId,$regionCode,$startDate,$endDate){
		$data = new SiteMonitorData();
		
		return $data->getRegionChart($pageId,$regionCode,$startDate,$endDate);
	}
	
	public static function getPageCountByTime($pageId,$startTime,$endTime,$timeType){
		$data = new SiteMonitorData();
		
		return $data->getPageCountByTime($pageId,$startTime,$endTime,$timeType);
	}
	
	public static function getSiteCountByTime($siteId,$startTime,$endTime,$timeType){
		$data = new SiteMonitorData();
		
		return $data->getSiteCountByTime($siteId,$startTime,$endTime,$timeType);
	}
	
	public static function getFeatureCountPerHour($featureId,$startDate,$endDate){
		if(!isset($featureId)){
			throw new BusinessException('专题id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		
		$data = new SiteMonitorData();
		
		return $data->getFeatureCountPerHour($featureId,$startDate,$endDate);
	}
	
	public static function getFeatureUserPieData($featureId,$startDate,$endDate){
		if(!isset($featureId)){
			throw new BusinessException('专题id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
	
		$data = new SiteMonitorData();
	
		return $data->getFeatureUserPieData($featureId,$startDate,$endDate);
	}
	
	public static function getPageUserPieData($pageId,$startDate,$endDate){
		if(!isset($pageId)){
			throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		
		$data = new SiteMonitorData();
		
		return $data->getPageUserPieData($pageId,$startDate,$endDate);
	}
	
	public static function getRegionAreaPerDay($pageId,$startDate,$endDate){
		if(!isset($pageId)){
			throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
	
		$data = new SiteMonitorData();
	
		return $data->getRegionAreaPerDay($pageId,$startDate,$endDate);
	}
	
	public static function getRegionArea($pageId,$startDate,$endDate){
		if(!isset($pageId)){
			throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		
		$data = new SiteMonitorData();
		
		return $data->getRegionArea($pageId,$startDate,$endDate);
	}
	
	public static function getExtensionClickRegionArea($pageId,$startDate,$endDate,$str){
	    if(!isset($pageId)){
	        throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
	    }
	    if(!isset($startDate)){
	        throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
	    }
	    if(!isset($endDate)){
	        throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
	    }
	    
	    $data = new SiteMonitorData();
	    
	    return $data->getExtensionClickRegionArea($pageId,$startDate,$endDate,$str);
	}
	
	public static function getClickCount($pageId,$startDate,$endDate){
		if(!isset($pageId)){
			throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		
		$data = new SiteMonitorData();
		
		return $data->getClickCount($pageId,$startDate,$endDate);
	}
	
	public static function getClickCountPerDay($channel,$startDate,$endDate){
		if(!isset($channel)){
			throw new BusinessException('页面id不能为空',self::DATA_EMPTY);
		}
		if(!isset($startDate)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}

		$data = new SiteMonitorData();
		
		return $data->getClickCountPerDay($channel,$startDate,$endDate);
	}
	
	public static function getSiteCountByFilter($filter){
		$data = new SiteMonitorData;
		
		return $data->getAll($filter);
	}
	
	public static function getAllPageCount($startTime,$endTime,$pageIds){
		if(!isset($startTime)){
			throw new BusinessException('开始时间不能为空',self::DATA_EMPTY);
		}
		if(!isset($endTime)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		$data = new SiteMonitorData;
		return $data->getAllPageCount($startTime,$endTime,$pageIds);
	}
}
